package com.lykj.lib_base.internal.utils

import com.blankj.utilcode.util.GsonUtils
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody


/**
 * ================================================
 * request Map参数转RequestBody
 * ================================================
 *
 * @author gosha
 * @date 2022/9/5-18:25
 */
object Map2RequestBodyUtils {
    open fun convert(params: HashMap<String, Any>): RequestBody {
        val bodyJson: String = GsonUtils.toJson(params)
        return bodyJson.toRequestBody(contentType = "application/json".toMediaTypeOrNull())
    }
}